﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Delegate.Chapter2
{
    public delegate void WorkPerformHandler(int hours, WorkType type);

    public class Program
    {
        static void Main(string[] args)
        {
            WorkPerformHandler del1 = new WorkPerformHandler(PerformHandler);
            WorkPerformHandler del2 = new WorkPerformHandler(PerformHandler2);

            del1.Invoke(5, WorkType.GenerateReports);
            del2.Invoke(10, WorkType.GoToMeetings);

            del1 += del2;
            del1(2, WorkType.Golf);


            Console.ReadLine();
        }

        static void DoWork(WorkPerformHandler del)
        {
            del(5, WorkType.Golf);
        }

        static void PerformHandler(int hours, WorkType type)
        {
            Console.WriteLine(hours + " " + type.ToString());
        }

        static void PerformHandler2(int hours, WorkType type)
        {
            Console.WriteLine(hours + " " + type.ToString() + " 2");
        }
    }

    public enum WorkType
    {
        GoToMeetings,
        Golf,
        GenerateReports
    }
}
